#include "UtilityPCH.h"

#include "UT_TimeHelper.h"
#include "UT_StringHelper.h"
#include "time.h"

using namespace Utility;
//----------------------------------------------------------------------------
//UT_TimeHelper
//----------------------------------------------------------------------------
bool UT_TimeHelper::GetSystemTimeStruct(uint64_t uiTime, tm& rkTime)
{
	memset(&rkTime, 0, sizeof(tm));
	time_t localTime = (time_t)uiTime;
	localtime_s(&rkTime,&localTime); 
	return false;
}
//----------------------------------------------------------------------------
CharType* UT_TimeHelper::GetSystemTimeString(uint64_t uiTime)
{
	static CharType szTimeToSec[50];
	
	struct tm kCurrentTimeStruct;
	GetSystemTimeStruct(uiTime,kCurrentTimeStruct);

	if (kCurrentTimeStruct.tm_year > 50)
	{
		UT_Sprintf(szTimeToSec, sizeof(szTimeToSec), "%04d-%02d-%02d %02d:%02d:%02d", 
			kCurrentTimeStruct.tm_year+1900, 
			kCurrentTimeStruct.tm_mon+1, 
			kCurrentTimeStruct.tm_mday,
			kCurrentTimeStruct.tm_hour, 
			kCurrentTimeStruct.tm_min, 
			kCurrentTimeStruct.tm_sec);
	}
	else
	{
		UT_Sprintf(szTimeToSec, sizeof(szTimeToSec), "%04d-%02d-%02d %02d:%02d:%02d",
			kCurrentTimeStruct.tm_year+2000, 
			kCurrentTimeStruct.tm_mon+1, 
			kCurrentTimeStruct.tm_mday,
			kCurrentTimeStruct.tm_hour, 
			kCurrentTimeStruct.tm_min, 
			kCurrentTimeStruct.tm_sec);
	}

	return szTimeToSec;
}